package com.guaoran.mybatis.mapper;


import com.guaoran.mybatis.bean.Dept;
import org.apache.ibatis.annotations.*;
import org.springframework.data.domain.Pageable;

import java.util.List;
import java.util.Map;

/**
 * @author : guCheng
 * @title : DeptMapper 
 * @Description : 
 * 	 
 * @date :2017年12月13日下午10:49:51
 */
@Mapper
public interface DeptMapper {
	/**
	 * 增加
	 * @param dept
	 */
	@Insert("insert into dept(name,age,create_time,demo_id) values(" +
			"#{name},#{age},#{createTime},#{demoId})")
	public void insertDeptByObject(Dept dept);

	/**
	 * 增加
	 * @param map
	 */
	@Insert("insert into dept(name,age,create_time,demo_id) values(" +
			"#{name,jdbcType=VARCHAR},#{age,jdbcType=INTEGER},#{create_time,jdbcType=TIMESTAMP},#{demo_id,jdbcType=INTEGER})")
	public void insertDeptByMap(Map<String,Object> map);

	/**
	 * 查询
	 * @param name
	 * @return
	 */
	@Select("select * from dept where name like CONCAT(concat('%',#{name}),'%' ) ")
	@Results({
			@Result(column = "id",property = "id"),
			@Result(column = "name",property = "name"),
			@Result(column = "age",property = "age"),
			@Result(column = "create_time",property = "createTime"),
			@Result(column = "demo_id",property = "demoId")
	})
	public List<Dept> queryDeptsByName(String name);

	/**
	 * 修改
	 * @param age
	 * @param name
	 * @return
	 */
	@Update("update dept set age=#{age} where name=#{name}")
	public int updateDeptAgeByName(@Param(value = "age") Integer age,@Param(value = "name") String name);

	/**
	 * 删除
	 * @param id
	 * @return
	 */
	@Delete("delete from dept where id = #{id}")
	public int deleteDeptByObject(Long id);
	public Pageable queryAllDemo(Pageable pageable);
}
